package com.cyx.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.lang.Nullable;
import org.springframework.web.servlet.View;
import org.springframework.web.servlet.ViewResolver;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.Locale;

/**
 * 定义自己的MVC扩展配置类
 * - 扩展视图解析器，向容器注册一个视图解析的Bean
 *    - 视图解析类(实现接口ViewResolver)
 */
@Configuration
public class MyMvcConfiguration implements WebMvcConfigurer{

    public static class MyViewResolver implements ViewResolver{
        @Nullable
        @Override
        public View resolveViewName(String viewName, Locale locale) throws Exception {
            return null;
        }
    }

    @Bean
    public ViewResolver myViewResolver(){
        return new MyViewResolver();
    }
}
